#!/usr/bin/env python

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # 
# Description:                                                          #
# Some examples of the Cython binding for the boost interval library.   #
#                                                                       #
# Author:                                                               #
#     Harald Schilly - harald.schilly@gmail.com                         #
#     2008, Vienna, Austria                                             #
#                                                                       #
# Copyright: ALL RIGHTS RESERVED                                        #
# License:   GPL v2+ (http://www.gnu.org/licenses/gpl-2.0.html)         #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #  

from BoostInterval import *

i1 = Interval(1,2)
i2 = Interval(3,4)

print i1
print i2

print "i1 + i2", (i1+i2)
print "i1 = ", i1
print "i2 = ", i2
print "i1 * ( i1 * i2) + i1", (i1*(i1*i2)+i1)

print "median: ", i1.median()
print "width:  ", i1.width()

i2 = Interval(99,99)
print "isSingleton(",i2,"): ", isSingleton(i2), " i2:", i2.isSingleton()

print "i1", i1, "i2", i2
print "i1+i1", (i1+i1)
print "i1+i2", (i1+i2)
print "i1-i1", (i1-i1)
print "i1/i1", (i1/i1)
print "i1/i2", (i1/i2)
print "i1*i2", (i1*i2)

print "sin(i2) =", sin(i2)
print "cos(i2) =", cos(i2)
print "tan(i2) =", tan(i2)

i1 = Interval(2,6)
i2 = Interval(4,8.91)
print "i1:", i1, "  i2:", i2

print "intersect(i1, i2) =", intersect(i1, i2)
print "i1.intersect(i2) = ", i1.intersect(i2)
print "i1.overlap(i2) =   ", i1.overlap(i2)
print "i1 in i2           ", i1 in i2

print "i1:                ", i1
print "i1.widen(4.5) =    ", i1.widen(4.5)

print "i1.bisect() =      ", i1.bisect()
print "i1.bisect(3) =     ", i1.bisect(3)
